let tab_title = ''

function display_h1 (h1 = '') {
  document.querySelector("#id1").innerHTML = "<p>tab title: " + tab_title + "</p><p>dom h1: " + h1 + "</p>"
}

chrome.tabs.query({active: true}, function(tabs) {
  let tab = tabs[0]
  tab_title = tab.title // 获取当前标签页的标题
  chrome.tabs.executeScript(tab.id, {
    code: 'document.querySelector("h1").textContent'
  }, display_h1) // 在当前标签页中执行脚本, 获取 h1 的内容并传入 display_h1 回调
})
